package com.zjp.common.core.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.net.InetAddress;
import java.util.List;
import java.util.Map;

// prefix注释 的值必须采用 kebab 大小写 （-）
@ConfigurationProperties("my.service")
@Configuration
@Data
public class MyProperties {

    @NotNull(message = "enabled not be value")
    private Boolean enabled;
    private InetAddress remoteAddress;
    private Security security;
    @Valid
    private Map<String, Security> securityMap;


    @Data
    public static class Security {
        @NotEmpty(message = "username not be value")
        private String username;

        private String password;

        private List<String> roles;


    }


}
